package io.github.handyang.algorithms.sort;

public class SelectionSortAlgorithms implements SortAlgorithms {

    @Override
    public void sort(int[] arr) {
        if (arr.length <= 1) return;

        for (int i = 0; i < arr.length; i++) {
            int minIndex = i;
            for (int j = i; j < arr.length; j++) {
                if (less(arr[j], arr[minIndex])) minIndex = j;
            }

            swap(arr, minIndex, i);
        }
    }
}
